package data

import (
	"log"

	"gorm.io/gorm"
)

var (
	migrate = false
	genData = false
)

var tables = []interface{}{}

func autoMigrate(db *gorm.DB) {
	if !migrate {
		return
	}
	if genData {
		log.Fatal("gen data success")
		return
	}
	if len(tables) > 0 {
		log.Println("auto migrate")
		err := db.AutoMigrate(tables...)
		if err != nil {
			log.Fatalf("auto migrate error: %v", err)
			return
		}
		log.Fatal("auto migrate success")
	}
}
